{include file="common/head"/}
    <div class="layui-form" style="bottom: 0; margin-left:0px;">
        <fieldset class="layui-elem-field layui-field-title">
            <legend>{:lang('list')}</legend>
        </fieldset>
        <div class="layui-form layui-border-box layui-table-view admin-main layui-anim" lay-filter="LAY-table-1" lay-id="content">
             <div class="layui-table-tool">
                <div class="layui-table-tool-temp"> <a href="/admin/article/add/catid/5.html" class="layui-btn layui-btn-sm">添加文章</a>
                  <button type="button" class="layui-btn layui-btn-danger layui-btn-sm" id="delAll">批量删除</button>
                  <a href="/admin/category/index.html" class="layui-btn layui-btn-normal layui-btn-sm">返回栏目</a> </div>
                <div class="layui-table-tool-self">
                  <div class="layui-inline" title="筛选列" lay-event="LAYTABLE_COLS"><i class="layui-icon layui-icon-cols"></i></div>
                  <div class="layui-inline" title="导出" lay-event="LAYTABLE_EXPORT"><i class="layui-icon layui-icon-export"></i></div>
                  <div class="layui-inline" title="打印" lay-event="LAYTABLE_PRINT"><i class="layui-icon layui-icon-print"></i></div>
                </div>
           </div>
          <div class="layui-table-box">
              <style>
                  .layui-table thead th { text-align:center;}
                  .layui-table-view .layui-table td,.layui-table-view .layui-table tr { padding:5px;}
				  .layui-form-checkbox[lay-skin=primary] { padding-left:5px;}
              </style>
              <table class="layui-table" style="width:100%;">
                <thead>
                  <tr>
                    <th style="width:40px;"><input type="checkbox" title="" id="did[]"  lay-skin="primary"  name="listid[]" value="{$r.did}" /></th>
                    <th width="4%">编号</th>
                    <th width="7%">排序</th>
                    <th width="50%">标题</th>
                    <th width="7%">点击</th>
                    <th width="18%">添加时间</th>
                    <th style="width:130px;">操作</th>
                  </tr>
                </thead>
                <tbody>
                {volist name="list" id="v"}
                  <tr>
                    <td style="text-align:center;width:40px;"><input type="checkbox" title="" id="did[]"  lay-skin="primary"  name="listid[]" value="{$v.id}" /></td>
                    <td style="text-align:center;">{$v.id}</td>
                    <td style="text-align:center;"><input name="50" data-id="50" class="list_order layui-input" value="{$v.sort}" size="10"></td>
                    <td>{$v.title}</td>
                    <td align="center">{$v.hits}</td>
                    <td>{$v.updatetime||date='Y-m-d H:i:s'}</td>
                    <td align="center"><div class="layui-btn-group" style="width:130px;">
                     <a href="https://show.cltphp.com/newsInfo-5-50.html" target="_blank" class="layui-btn layui-btn-xs layui-btn-normal">预览</a> 
                     <a href="/admin/article/edit.html?id=50&amp;catid=5" class="layui-btn layui-btn-xs">编辑</a> 
                     <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a> </div></td>
                  </tr>
                  {/volist}
                </tbody>
              </table>
          </div>
          <div class="c"></div>
          <div id="pages">{$list|raw}</div>
        </div>
    </div><!--内框-->
{include file="common/foot"/}
<script>
    layui.use('table', function() {
        var table = layui.table, $ = layui.jquery;
        
        //搜索
        $('#search').on('click', function () {
            var key = $('#key').val();
            if ($.trim(key) === '') {
                layer.msg('{:lang("pleaseEnter")}关键字！', {icon: 0});
                return;
            }
            tableIn.reload({ page: {page: 1}, where: {key: key,catid:'{:input("catid")}'} });
        });
        $('body').on('blur','.list_order',function() {
            var id = $(this).attr('data-id');
            var sort = $(this).val();
            var loading = layer.load(1, {shade: [0.1, '#fff']});
            $.post('{:url("listorder")}',{id:id,sort:sort,catid:'{:input("catid")}'},function(res){
                layer.close(loading);
                if(res.code === 1){
                    layer.msg(res.msg, {time: 1000, icon: 1}, function () {
                        location.href = res.url;
                    });
                }else{
                    layer.msg(res.msg,{time:1000,icon:2});
                }
            })
        });
        table.on('tool(list)', function(obj) {
            var data = obj.data;
            if(obj.event === 'del'){
                layer.confirm('您确定要删除该内容吗？', function(index){
                    var loading = layer.load(1, {shade: [0.1, '#fff']});
                    $.post("{:url('listDel')}",{id:data.id},function(res){
                        layer.close(loading);
                        if(res.code===1){
                            layer.msg(res.msg,{time:1000,icon:1});
                            tableIn.reload({where:{catid:'{:input("catid")}'}});
                        }else{
                            layer.msg('操作失败！',{time:1000,icon:2});
                        }
                    });
                    layer.close(index);
                });
            }
        });
        $('body').on('click','#delAll',function() {
            layer.confirm('确认要删除选中的内容吗？', {icon: 3}, function(index) {
                layer.close(index);
                var checkStatus = table.checkStatus('content'); //content即为参数id设定的值
                var ids = [];
                $(checkStatus.data).each(function (i, o) {
                    ids.push(o.id);
                });
                var loading = layer.load(1, {shade: [0.1, '#fff']});
                $.post("{:url('delAll')}", {ids: ids,catid:'{:input("catid")}'}, function (data) {
                    layer.close(loading);
                    if (data.code === 1) {
                        layer.msg(data.msg, {time: 1000, icon: 1});
                        tableIn.reload({where:{catid:'{:input("catid")}'}});
                    } else {
                        layer.msg(data.msg, {time: 1000, icon: 2});
                    }
                });
            });
        })
    });
</script>